<template>
  <div>
    <h1>ts类型</h1>
  </div>
</template>

<script setup lang="ts">
//TypeScript 在较新版本中要求使用 import type 来导入类型，而不是 import。
//Vue 正确识别这是一个 TypeScript 组件
//正确导入了类型定义
//符合现代 TypeScript 的最佳实践
import type { Person, Persons } from "@/types/index";
let person: Person = { name: "张三", age: 18 };
//<T>泛型
let personList: Array<Person> = [
  { name: "张三", age: 18 },
  { name: "王五", age: 20 },
];
let personList2: Persons = [
  { name: "张三", age: 18 },
  { name: "王五", age: 20 },
];
let personList3: Person[] = [
  { name: "张三", age: 18 },
  { name: "王五", age: 20 },
];
</script>

<style scoped></style>
